﻿using System.Data.Entity.ModelConfiguration.Conventions;
using Entity.Mapping;
using Entity.Migrations;
using Entity.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entity.Context
{
    public partial class Context : DbContext
    {
        static Context()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<Context, Configuration>());
        }

        public Context()
            : base("SgfDb")
        { }
        public DbSet<Banco> Banco { get; set; }
        public DbSet<CategoriaDespesa> CategoriaDespesa { get; set; }
        public DbSet<CategoriaRecebimento> CategoriaRecebimento { get; set; }
        public DbSet<Deposito> Deposito { get; set; }
        public DbSet<Despesa> Despesa { get; set; }
        public DbSet<Recebimento> Recebimento { get; set; }
        public DbSet<Usuario> Usuario { get; set; }
        public DbSet<Configuracao> Configuracao { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new BancoMap());
            modelBuilder.Configurations.Add(new CategoriaDespesaMap());
            modelBuilder.Configurations.Add(new CategoriaRecebimentoMap());
            modelBuilder.Configurations.Add(new DepositoMap());
            modelBuilder.Configurations.Add(new DespesaMap());
            modelBuilder.Configurations.Add(new RecebimentoMap());
            modelBuilder.Configurations.Add(new UsuarioMap());
            modelBuilder.Configurations.Add(new ConfiguracaoMap());

            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
        }
    }
}
